<h3 class="side_header">
    <span data-expand="1" class="br icon icon_exp" onclick="btn_util.toggle_expand_all(this, '#block_privileges')"></span>
    <span>Các quyền được gán</span>
</h3>
<?php if (count($privileges) > 0 && $privileges) :?>
<div class="db_side_block">
    <div class="db_side_header" style="cursor: pointer" onclick="return btn_util.toggle_expand(this)">
        <span class="br icon icon_exp"></span><strong>[Các quyền định nghĩa]</strong>
    </div>
    <div class="db_inner_content" style="display: none">
        <ul class="lst_role">
            <?php foreach ($privileges as $privilege) :?>
            <li>
                <label>
                    <input class="std_chk" type="checkbox" />
                    <strong><?php echo $privilege->name; ?></strong>
                </label>
            </li>
            <?php endforeach; ?>
        </ul>
    </div>
</div>
<?php endif; ?>
<?php foreach ($system_privileges as $group) :?>
<div class="db_side_block">
    <div class="db_side_header" style="cursor: pointer" onclick="return btn_util.toggle_expand(this)">
        <span class="br icon icon_exp"></span><strong>[<?php echo $group['name']; ?>]</strong>
    </div>
    <div class="db_inner_content" style="display: none">
        <ul class="lst_role">
            <?php $system_index = 1; foreach ($group['children'] as $privilege) :?>
            <li>
                <label>
                    <input <?php if (in_array($privilege['alias'], $role->system_privileges)) :?>checked="checked"<?php endif; ?> value="<?php echo $privilege['alias']; ?>" class="std_chk" type="checkbox" />
                    <strong><?php echo $privilege['name']; ?></strong>
                </label>
            </li>
            <?php $system_index++; ?>
            <?php endforeach; ?>
        </ul>
    </div>
</div>
<?php endforeach; ?>